<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>创建活动</title>

    <%include ../../common.ejs%>
    <style>


        .main ._caption {
            font-size: 30px;;
        }

        .input-costom {

            width: 130px;
            margin-right: 0px;
        }

        .marginTB20{margin: 20px 0px;}

        ._five .form-group ._five textarea {
            width: 200px;
        }
    </style>
    <script type="text/javascript" src="../../javascripts/bootstrap-datetimepicker.js"></script>
    <script type="text/javascript" src="../../javascripts/bootstrap-datetimepicker.min.js"></script>
    <script type="text/javascript" src="../../javascripts/bootstrap-datetimepicker.zh-CN.js"></script>
    <script type="text/javascript">
        $(function () {
            $('.form_datetime').datetimepicker({
                format: 'yyyy-mm-dd',
                language: 'zh-CN',
                minView: "month",
                autoclose:true});
        })
        //获得当前时间字符串
        function CurentTime()
        {
            var now = new Date();

            var year = now.getFullYear();       //年
            var month = now.getMonth() + 1;     //月
            var day = now.getDate();            //日

            var hh = now.getHours();            //时
            var mm = now.getMinutes();          //分
            var ss=now.getSeconds();            //秒

            var clock = year + "-";

            if(month < 10) clock += "0";
            clock += month + "-";

            if(day < 10) clock += "0";
            clock += day + " ";

            if(hh < 10) clock += "0";
            clock += hh + ":";

            if (mm < 10) clock += '0';
            clock += mm+ ":";

            if (ss < 10) clock += '0';
            clock += ss;

            return(clock);
        }
        //验证地址
        function validate_location(){
            {
                if ($("#location").val() == "") {
                    $("#msg2").empty();
                    return false;
                }
                var loc = $("#location").val();
                var length =loc.length;
                if (length=0 || length>199)
                {
                    $("#msg2").html("<img src='/images/icons/failure.png' style='height: 25px;width: 25px;'>");
                    return false;
                }
                else {  $("#msg2").html("<img src='/images/icons/success.png' style='height: 25px;width: 25px;'>");}

            }
        }//验证内容
        function validate_content(){
            {
                if ($("#content").val() == "") {
                    $("#msg6").empty();
                    return false;
                }
                var con = $("#content").val();
                var length =con.length;
                if (length=0 || length>199)
                {
                    $("#msg6").html("<img src='/images/icons/failure.png' style='height: 25px;width: 25px;'>");
                    return false;
                }
                else {  $("#msg6").html("<img src='/images/icons/success.png' style='height: 25px;width: 25px;'>");}

            }
        }

        //验证开始时间
        function validate_startTime()
        {
            if ($("#startTime").val() == "") {
                $("#msg3").empty();
                return false;
            }

            if ($("#startTime").val()<CurentTime())
            {
                $("#msg3").html("<img src='/images/icons/failure.png' style='height: 25px;width: 25px;'>");
                return false;
            }
            else {  $("#msg3").html("<img src='/images/icons/success.png' style='height: 25px;width: 25px;'>");}

        }
        //验证结束时间
        function validate_endTime()
        {
            if ($("#endTime").val() == "") {
                $("#msg4").empty();
                return false;
            }

            if ($("#endTime").val()<CurentTime() || ($("#endTime").val()>$("startTime").val()))
            {
                $("#msg4").html("<img src='/images/icons/failure.png' style='height: 25px;width: 25px;'>");
                return false;
            }
            else {  $("#msg4").html("<img src='/images/icons/success.png' style='height: 25px;width: 25px;'>");}

        }

        //验证主题
        function validate_subject()
        {
            if ($("#subject").val() == "") {
                $("#msg1").empty();
                return false;
            }
            var sbj = $("#subject").val();
            var length =sbj.length;
                if (length=0 || length>20)
                {
                    $("#msg1").html("<img src='/images/icons/failure.png' style='height: 25px;width: 25px;'>");
                    return false;
                }
                else {  $("#msg1").html("<img src='/images/icons/success.png' style='height: 25px;width: 25px;'>");}

        }


        //验证活动人数
        var validate_number = function () {
            if ($("#number").val() == "") {
                $("#msg5").empty();
                return false;
            }
            var num = $("#number").val(); //获取活动人数
            var numReg = parseInt(num);
            //如果数据不能通过验证
            if (numReg<0 ||numReg>1000) {
                $("#msg5").html("<img src='/images/icons/failure.png' style='height: 25px;width: 25px;'>");
                return false;
            } else {
                $("#msg5").html("<img src='/images/icons/success.png' style='height: 25px;width: 25px;'>");
            }
        }
        //验证表单
        var checkAll = function () {
            if (validate_location() == false) {
                return false;
            }
            if (validate_content()==false){
                return false;
            }
            if (validate_subject()==false){
                return false;
            }if (validate_startTime()==false){
                return false;
            }if (validate_endTime()==false){
                return false;
            }
            if (validate_number()==false){
                return false;
            }
        }
        //提交验证
        function submitForm() {
            if (checkAll() == false) {
                return false;
            }
        }


    </script>


</head>
<body  >
<div id="top">
    <% include ../top.ejs%></div>
<div class="container-fluid" style="margin-top: 20px;">
    <div class="row">
        <div class="col-md-1">
        </div>
        <div id="left" class="col-md-2">
            <% include ../left.ejs%>
        </div>
        <div class="col-md-8 bodyDiv" id="right">


            <div class="main">
                <form method="post" action="/admin/activityManage/addActivity" >
                    <div>
                   
                    <span class="_caption">创建活动</span>
                    </div>
                    <div class="row marginTB20">
                        <div class="col-md-6 ">
                            <div class="col-md-5">
                                <span style="font-size: 20px">活动主题</span>
                            </div>
                            <div class="col-md-6">
                                <input type="text" name="subject" id="subject"  onblur="validate_subject()"  class="form-control input-costom" required oninvalid="setCustomValidity('请填写活动主题');" oninput="setCustomValidity('');">
                            </div>
                            <div class="col-md-1" id="msg1"></div>
                        </div>
                        <div class="col-md-6  ">

                            <div class="col-md-5">
                                <span style="font-size: 20px">活动地点</span>
                            </div>
                            <div class="col-md-6">
                                <input type="text" name="location"  id="location" onblur="validate_location()" class="form-control input-costom " required oninvalid="setCustomValidity('请填写活动地点');" oninput="setCustomValidity('');">
                            </div>
                            <div class="col-md-1" id="msg2"></div>

                        </div>
                    </div>

                    <div class="row marginTB20">
                        <div class="col-md-6 ">
                            <div class="col-md-5">
                                <span style="font-size: 20px">开始时间</span>
                            </div>
                            <div class="col-md-6">
                               <input type="text" name="startTime" id="startTime" onblur="validate_startTime()" style="width: 130px" class="form-control input-costom  form_datetime" required oninvalid="setCustomValidity('请填写活动时间');" oninput="setCustomValidity('');">
                            </div>
                            <div class="col-md-1" id="msg3"></div>
                        </div>
                        <div class="col-md-6  ">

                            <div class="col-md-5">
                                <span style="font-size: 20px">结束时间</span>
                            </div>
                            <div class="col-md-6">
                                <input type="text" name="endTime" id="endTime"onblur="validate_endTime()" style="width: 130px" name="number" class="form-control input-costom  form_datetime">  <!--required oninvalid="setCustomValidity('请填写活动人数');" oninput="setCustomValidity('');"-->
                            </div>
                            <div class="col-md-1" id="msg4"></div>
                        </div>
                    </div>


                    <div class="row marginTB20">
                        <div class="col-md-6 ">
                            <div class="col-md-5">
                                <span style="font-size: 20px">活动人数</span>
                            </div>
                            <div class="col-md-6">
                                <input type="text"  id="number" name="number" onblur="validate_number()"  class="form-control input-costom" required oninvalid="setCustomValidity('请填写活动人数');" oninput="setCustomValidity('');">
                            </div>
                            <div class="col-md-1" id="msg5"></div>

                        </div>
                        <div class="col-md-6  "></div>
                    </div>

                    <div class="row marginTB20">
                        <div class="col-md-6 ">
                            <div class="col-md-5">
                                <span style="font-size: 20px">活动内容</span>
                            </div>
                            <div class="col-md-6">
                            <div class="col-md-1" id="msg6"></div>
                            </div>
                        </div>
                        <div class="col-md-6  ">
                        </div>
                    </div>

                    <div class="row marginTB20">

                        <div class="col-md-12">
                            <div class="form-group">
                                <textarea class="form-control" id="content"  name="content" rows="3" onblur="validate_content()" required oninvalid="setCustomValidity('请填写活动内容');" oninput="setCustomValidity('');"></textarea>
                            </div>

                        </div>

                    </div>
                    <div class="row marginTB20">
                        <div class="col-md-8"></div>
                        <div class="col-md-2">
                        </div>
                        <div class="col-md-2">
                            <input type="submit" class="btn btn-primary" onclick="return submitForm()">
                            <% if(users==0){%>
                            <% }%>
                            <% if(users!=0){%>
                            <script>alert("success!")</script>
                            <% }%>
                        </div>
                    </div>
                </form>
            </div>
        </div>

    </div>
</div>
</div>
</body>
</html>